<include file="Public/head" />
</head>
<body>

<include file="Public/common_header" />

<div class="mian">
    <include file="Public/sidebar" menu='zhgl.ygzh' />

    <form id='ct_fm' action="/Emp/ci_group_save" method="post">
        <input type="hidden" name="group_id" value="{$group.id}" />
        <div class="mianR">
            <h3 class="yonghu"><?php echo ($_GET['group_id']?'编辑':'新建');?>分组</h3>
            <div class="new-fenzu">
                <dl>
                    <dt class="clearfix">
                        <span>分组名称</span>
                        <input type="text" name="title" value="{$group.title}" />
                        <span>分组描述</span>
                        <input type="text" name="remark" value="{$group.remark}" />
                    </dt>
                    <dd>
                        
                        <div class="xinzeng clearfix">                        
                            <h4>权限分配</h4> <input type="button" onclick="create_emp();" value="新增权限" /> </a>
                        </div>
                        <foreach name="rule_list" item="rule" key="k" >
                            <if condition="($rule.pid eq 0)"> 
                                <if condition="($k neq 0)"></em> </if>
                                <span><input type="checkbox" <?php echo (in_array($rule['id'], $group['rule_id'])?'checked':''); ?>  name="rule_id[]" value="{$rule.id}" />{$rule.title}</span> 
                                <em class="clearfix">
                            <else /> 
                                <i><input type="checkbox" <?php echo (in_array($rule['id'], $group['rule_id'])?'checked':''); ?>  name="rule_id[]" value="{$rule.id}"  />{$rule.title}</i>  
                            </if>
                        </foreach>

                        <!-- <span><input type="checkbox" />卖车用户</span> 
                        <em class="clearfix">
                            <i><input type="checkbox"  name="rule_id[]" value="1"  />待预约</i>  
                            <i><input type="checkbox"  name="rule_id[]"  value="2"  />跟踪中</i> 
                            <i><input type="checkbox"  name="rule_id[]"  value="3"  />预约成功</i>
                            <i><input type="checkbox"  name="rule_id[]"  value="4" />预约失败</i>
                            <i><input type="checkbox"  name="rule_id[]"  value="5"  />新增用户信息</i>
                        </em> 
                        
                        
                        <span><input type="checkbox" />卖车用户</span> 
                        <em class="clearfix">
                            <i><input type="checkbox"  name="rule_id[]" value="6" />待预约</i>  
                            <i><input type="checkbox"  name="rule_id[]" value="7" />跟踪中</i> 
                            <i><input type="checkbox"  name="rule_id[]" value="8" />预约成功</i>
                            <i><input type="checkbox"  name="rule_id[]"value="9"  />预约失败</i>
                            <i><input type="checkbox"  name="rule_id[]" value="10" />新增用户信息</i>
                        </em>  -->

                    </dd>
                </dl>
            </div>
            <div class="yongBtn">
                <input type="button" onclick="return Submit();" value="确定" class="queding" />
                <input name="重置" type="reset" class="quxiao" onclick="history.go(-1);"  value="取消" />
            </div>
        </div>
    </form>
</div>

</div>
<div class="clear"></div>
</div>





<include file="add_rule" />


<script>
    $('dd span input').click(function(){
        var checked = (this.checked?true:false);
        $.each($(this).parent().next('.clearfix').find('input'),function(i,n){
            n.checked=checked;
        });
    })
    $('dd em i input').click(function(){            
        if($(this).parent().parent().find("input:checked").length>0){
            $(this).parents("em").prev("span").find("input").prop("checked",true);
        }else{
            $(this).parents("em").prev("span").find("input").removeProp("checked");
        }
    })
</script>
<script>
    function Submit(){
        post_submit_json('ct_fm',function(data){
            //成功回调
            delay_alert('操作成功',300);
            setTimeout(function (){location.href='/Emp/group_list';},400);
        })    
        return false;
    }

</script>
<include file="Public/foot" />